home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-20 | 54.0 KB | 1,304 lines |
- Newsgroups: comp.sources.misc
- From: kirsch@usasoc.soc.mil (David Kirschbaum)
- Subject: v23i091: zip - Portable zip v1.0, Part04/09
- Message-ID: <1991Oct21.042120.7985@sparky.imd.sterling.com>
- X-Md4-Signature: 112dd94095c7c795ea81a3ef538d0afb
- Date: Mon, 21 Oct 1991 04:21:20 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: kirsch@usasoc.soc.mil (David Kirschbaum)
- Posting-number: Volume 23, Issue 91
- Archive-name: zip/part04
- Environment: UNIX, Minix, MSDOS, OS/2, VMS
-
- #! /bin/sh
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # Contents: History makefile.pwc shrink.c zip.def
- # Wrapped by kent@sparky on Sun Oct 20 22:58:53 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 4 (of 9)."'
- if test -f 'History' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'History'\"
- else
- echo shar: Extracting \"'History'\" \(36825 characters\)
- sed "s/^X//" >'History' <<'END_OF_FILE'
- XNote, this history contains mail addresses and ftp locations that no longer
- Xexist, such as addresses at wsmr-simtel20 and directory names containing
- Xw8sdz, among others. For problems, the correct email address is
- Xzip-bugs@cs.ucla.edu.
- X
- X------------------------ Nov 7 1990 version 0.0 ------------------------
- X------------------------ Nov 8 1990 version 0.1 ------------------------
- X------------------------ Nov 12 1990 version 0.2 ------------------------
- X------------------------ Nov 14 1990 version 0.3 ------------------------
- XThank you for your comments. Here is Zip 0.3 with almost all of that fixed.
- XThe changes include:
- X
- X1. Put \n\ for newlines in long strings (everyone had this problem).
- X2. Wrote my own bsearch (called search---different args).
- X3. Wrote my own timelocal (called invlocal), used whether STDC or not.
- X (Note to Greg: look at the code---I found a simple way to do it.)
- X4. -m now deletes empty directories also.
- X5. Changed crc.c to util.c and put search() in util.c.
- X6. Changed "void *" to "voidp *" and made voidp void for STDC, else char.
- X7. Removed -a option.
- X8. Some minor changes to zip.doc.
- X
- XI did not do anything about Cliff Manis's problem with DIR not being
- Xdefined. DIR should have been defined in sys/dir.h. If it wasn't, then
- Xthere's something wrong with dir.h, or it is missing, or the opendir, etc.
- Xfunctions are missing. I don't really want to think about what to do for
- Xthe latter possibility.
- X
- XNUnzip 3.99 does not appear to be Unix-ready. It fails for file names longer
- Xthan 12 characters (Segmentation fault), cannot find explicit names that
- Xdo not contain a dot, and does not notice the Unix identifier (which should
- Xswitch off name to lower-case mapping).
- X
- X------------------------ Nov 20 1990 version 0.4 ------------------------
- XYo Zippers,
- X
- XHere is a first attempt at a Zip intended to work on System V. Try using
- X"make sysv" for such systems. I also included replacements for memset()
- Xand memcmp() by Bill Davidsen and James Dugal for systems without those.
- XUse "make old" to include those routines. Sun's use getdents() like Sys V,
- Xeven though it's BSD, so use "make sun". For others, try just "make".
- X
- XWhen using "make" a second time with a different request, it's best to erase
- Xall the .o files to force recompiling everything.
- X
- XWhat follows are the changes I made and some things to try if you get it
- Xcompiled. Have fun.
- X
- XMark
- X
- X
- XChanges from Zip 0.3 to Zip 0.4:
- X
- X1. Changed third arg of search() to size_t to make lint happier.
- X2. Replaced zip.doc with a man page, zip.1 (raw) and zip.man (formatted).
- X3. rename() replaced with link() and unlink().
- X4. Fixed vem in central header and added REVISION and REVDATE #define's
- X to zip.h. (Didn't read Phil's appnote.txt carefully enough there.)
- X5. Removed prototypes except for development host (NeXT). (They're only
- X there for my benefit anyway---they should not affect the resulting
- X code. Consider them some meager documentation.)
- X6. Changed rindex() to strrchr().
- X7. Improved behavior on a write failure when -b is used.
- X8. Added Bill Davidsen's and James Dugal's memset(), memcpy(), and
- X memcmp() routines under the trusty ZMEM #define.
- X9. Check that zip file is writeable before doing any real work.
- X10. Added #ifdef REGEX to use regcmp(), regex() instead of re_comp(),
- X re_exec(). (We'll see if this works.)
- X11. Replaced opendir(), readdir(), closedir() with my own opend(), readd(),
- X and closed() routines that use getdirentries() on BSD and getdents() on
- X System V (I hope) and Sun's. An #ifdef DIRENT selects getdents().
- X12. zip.h no longer #includes string.h, instead defining the string
- X functions used explicitly.
- X
- X
- XIf you get Zip 0.4 to compile, here are some things to test:
- X
- X1. Try zipping up some stuff, of course. Use all the options that are
- X implemented. Especially try -rp and -rpm on a directory tree (use
- X *test* files and directories, of course).
- X2. Naturally check with unzip -t, but also check with "zip xxx" where
- X xxx.zip is the zip file. This should say "nothing to do", but if it
- X says "error in zip file structure", there's a problem.
- X3. After zipping, check that there are no $Z* files leftover.
- X4. Try using -b, specifying a path on another device. Check for $Z*'s.
- X5. Try -d and a regular expression (like \*.o) on a zip file.
- X6. And I'm interested in timing---try it on a 500K or so text file.
- X
- X------------------------ Nov 27 1990 version 0.5 ------------------------
- XHail fellow zippers,
- X
- XHere's Zip 0.5. The biggie is it now includes implosion, courtesy of Rich
- XWales. Even as we speak, he is working on new algorithms for implode that
- Xpromise to be significantly faster. He might even get a paper out of it ...
- X
- XYou can use the -s option (shrink only) when testing to save a little time,
- Xbut also try it normally to test implosion (if you test with text files
- Xof reasonable length, implosion will be chosen for most of them). Also, for
- Xspeed testing of implosion, use -i to not waste time trying to shrink.
- X
- XIncluding implosion about doubles the size of zipnn.tar.Z, so I would like
- Xsome input on distributing subsequent versions. Would y'all like to keep
- Xon getting the uuencoded version via mail, or would you prefer a notice
- Xabout availability via anonymous ftp on simtel20.army.mil in <w8sdz.zip>?
- X(I have been sending the previous versions to Keith to put there, and will
- Xcontinue to do so. I do not know what the lag time is for him to move it
- Xthere.)
- X
- XThe other important change is that this is another attempt at getting the
- Xdirectory access routines working on all systems. Read the installation
- Xpart of the manual page (zip.man). And if you feel like, read the whole
- Xthing. I'm also taking suggestions for and bugs in the documentation.
- X
- XThe differences from Zip 0.4 include:
- X
- X1. Changed all occurences of "size_t" to "extent" and typedef'ed extent
- X to size_t (after an #include <stddef.h>) for ANSI C, or unsigned int
- X otherwise. If anyone finds that they have a non ANSI C, that size_t
- X is defined, and that it is not the size of the compiler's int, then
- X please let me know.
- X2. Changed help() to put the help text in a static array of strings and
- X then printf() for each line. Some compilers barfed on the long
- X string. Suggested by davidsen@crdos1.crd.ge.com.
- X3. Added Rich Wales' implode routines, made their inclusion the default
- X (changed #ifdef IMPLODE to #ifndef NOIMPLODE).
- X4. Put "extern int errno;" in unixfile.c (redundant extern's should be ok).
- X5. Minor changes to the man page (zip.1 and zip.man).
- X6. Added warnings for names given on the command line that are not matched.
- X Lack pointed out by grimesg@sj.ATE.SLB.COM (George).
- X7. Changed back to opendir(), etc. on BSD systems.
- X8. Added NDIR #define for HPUX to #include <ndir.h> instead of <sys/dir.h>.
- X9. Redid Makefile, adding next (use shared library), sysvpw (System V's
- X that require linking the libPW library for regex routines), and hpux
- X (see #8 above).
- X
- XAs usual, report problems to info-zip@wsmr-simtel20.army.mil. If you wish,
- Xyou can, in addition, send the same report to me (madler@piglet.caltech.edu)
- Xor Rich (wales@cs.ucla.edu) if the problem is with implosion (i* files) for
- Xquicker reponse.
- X
- Xyour humble servant,
- XMark Adler
- X------------------------ Dec 7 1990 version 0.6 ------------------------
- XGreetings and Felicitations Honorable Zip Compatriots,
- X
- XI have uploaded Zip 0.6, which incorporates most of your helpful comments,
- Xto Simtel20.Army.Mil, and it should evenually end up in <W8SDZ.ZIP> as
- XZIP06.TAR-Z. The most significant change is the addition of encryption
- Xboth as the -e option in Zip, and a new program, ZipCloak, that encrypts
- Xand decrypts zip entries. This surely adds some new portability problems,
- Xdue to the getp() routine which reads a password from the terminal with no
- Xechoing. We'll see how well this flies ...
- X
- XIf someone wants to PKZIP up the tar.Z file, please do so. I didn't zip
- Xit up myself because a) I'm lazy, and b) PKZIP can compress it better
- Xanyhow, and I don't have a PC.
- X
- XAlso, there is an EXPORT symbol used to remove encryption, so I can make
- Xan export version that does not have -e or ZipCloak. This version will
- Xsimply be missing a few source files and have a different Makefile.
- X
- XI also added a few systems to the Makefile, and made some other changes to
- Xit based on all your detailed comments. If it still works after all that,
- XI'll be amazed.
- X
- XThose and other changes from 0.5 to 0.6 are detailed at the end of this note.
- X
- XI have not addressed the portability problem with the implode routines,
- Xsince that is Rich's domain. I have no idea what is causing it. (For those
- Xwho don't know, one system produced remarkable 90% compression rates with
- Ximplode, but alas, it is a bug.)
- X
- XOne fellow complained that zipping up the README file results in a zip file
- Xthat is larger than the original, even though Zip claims it compressed it.
- XWell, it did compress it, but the ZIP file format has an overhead of
- X76+2*N bytes per file+22 bytes, where N is the length of the file name.
- XAnd that's without comments or "extra" information. So, a zip file with a
- Xsingle file whose name has six characters has an overhead of 110 bytes.
- XREADME gets shrunk by 16% from 274 bytes to 230 bytes, resulting in a total
- Xzip file size of 340 bytes---larger than the original file (274 bytes).
- XThe moral is don't expect zip to compress a single small file. The other
- Xmoral is use unzip -v to see the compression.
- X
- XSomeone else asked about multi-disk zip files. I'm not sure I believe in
- Xthose, since PKZIP and PKUNZIP do not appear to suppport them (though it is
- Xpart of the ZIP file definition in APPNOTE.TXT). What I was planning on
- Xdoing for that case was to write a ZipSplit program that would take a large
- Xzip file and try to optimally split it into the fewest number of zip files
- Xthat are all less than the specified size. Each would be a complete, stand
- Xalone zip file---not part of a single, multi-disk zip file. There would
- Xalso be a ZipMerge program.
- X
- XThis is the version of Zip that will live in infamy (note the revision date).
- XOf course, some current Presidents of the United States think that should be
- XSeptember 7th, but I won't name any names.
- X
- XI am going on vacation for about two weeks, so I expect to find many new
- Xproblems reported upon my return.
- X
- XAnd lastly, for my Holiday Greetings: Party On Dudes.
- X
- XMark Adler
- Xmadler@piglet.caltech.edu
- X
- X
- XHere are the changes from Zip 0.5 to Zip 0.6:
- X
- X1. Minor documentation changes (zip.1 and zip.man).
- X2. Fixed an embarrasing lack of recursion in opend/readd/closed functions
- X that only existed in 0.5.
- X3. Moved $(LDFLAGS) to end of the linking command line in Makefile.
- X4. Added make dnix for DNIX 5.2, 5.3 not using optimization (no -O).
- X5. Wrote ZipCloak for encryption and decryption.
- X6. Rich changed the output routines of implode to use zfwrite and zputc to
- X provide hooks for encryption (defined in crypt.h). Also removed
- X function prototypes unless PROTO defined.
- X7. Added encryption (-e) to Zip.
- X8. Added make pyramid (use rindex() instead of strrchr()).
- X9. Changed make to $(MAKE) and cc to $(CC) in Makefile.
- X10. Took out strip in Makefile.
- X11. Changed year from 1991 to 1990. (How'd *that* get in there? Of course,
- X it's not as bad as when I wrote a check the other day and dated it 1977.
- X I think my brain cell isn't working as well as it used to.)
- X12. Added make cray (use scc instead of cc).
- X13. Added make amdahl (use system() instead of rmdir()).
- X14. Added entry of one-line comments for added files (-c).
- X15. Put comment delimiters around name following #endif's in Rich's code.
- X
- X------------------------ Feb 13 1991 version 0.7 ------------------------
- XFellow stuck zippers,
- X
- XWell folks, it's been a while since 0.6. so there have been a lot of
- Xchanges on the way to 0.7. The exhaustive listing is below, but here are
- Xsome highlights ...
- X
- XImplode now (appears) to be PKUNZIP compatible. There were many odd
- Xlittle requirements implosed by the coding of PKUNZIP that were obtained
- Xfrom Phil Katz and associates. Now that Rich has that working, he will
- Xlikely be working on much faster string matching routines to speed up
- Ximplode.
- X
- XUser interrupts (control-C or kill) are now caught and the temporary files
- Xare deleted, making for a clean getaway.
- X
- XSelf-extracting zip files for MSDOS can now be processed, with the
- Xextensions zip, ZIP, exe, or EXE. This allows you to make self-extracting
- Xzip files for MSDOS by taking an existing one (like PKZ110.EXE) and
- Xdeleting all the entries to get a prototype self-extracting zip file that
- Xcan be copied and added to. Of course, you should only do this if you are
- Xa registered user of PKZIP. Note that if the file does not end in .zip,
- Xyou have to give the full name.
- X
- XI have relaxed some of the restrictions on zip files to allow processing
- Xones with "authenticity verification" (applied by the PUTAV program that
- Xcomes with PKZIP). Of course, the authenticity no longer checks out if
- Xyou muck with the file, but at least you can muck with it now.
- X
- XThe Makefile has been considerably simplified, thanks to suggestions from
- XJean-Loup Gailly. Also, I wrote my own sh expression matcher, eliminating
- Xthe regular expression hassles, and the REGEX symbol and -lPW options in
- Xthe Makefile.
- X
- XMany, many cosmetic changes, the most dangerous of which was turning on
- Xprototypes again in the hopes we can get them to work. If they cause you
- Xproblems, record the problems (for me), and then add a -DNOPROTO to the
- Xappropriate line in the Makefile and try again.
- X
- XThis version now compiles under Microsoft C 5.1 and Turbo C++ 1.0, with
- Xmuch thanks to Jean-Loup Gailly. I say "compiles" and not "works" because
- XI have not thoroughly tested it. It does work, but there may be errors in
- Xthe port as well as errors in the design. By the latter I mean that there
- Xmay be some disagreement over what you expect it to do and what it does,
- Xespecially with regards to upper and lower case names and wildcard
- Xpatterns. Also, the implode routines do not yet work under MSDOS, so the
- Xcompilations are done using NOIMPLODE. There are two dumb batch files to
- Xdo the compile: doturboc.bat and domsc.bat. If someone would like to
- Xwrite make files for the make utilities that come with those languages,
- Xplease be my guest. I'm just too lazy. However, I would probably resist
- Xincluding make files that require a make utility that does not come with
- Xthose languages, be it commercial, shareware, or free.
- X
- XThere are two new programs: ZipSplit and Ship. ZipSplit tries to split a
- Xbig zip file into the smallest number of zip files less than a specified
- Xsize. This is to aid in using zip to backup to floppies. It has the
- Xlimitation that it cannot break up an entry in a zip file, since it makes
- Xcomplete, standalone zip files. This means if any entry is larger than
- Xthe specified size (plus some overhead), zipsplit will give up and not do
- Xthe split. It does *not* implement the multi-disk zip file format implied
- Xin APPNOTE.TXT. ZipSplit will optionally write an index file and deduct
- Xthe size of that file from the first zip file so both will fit on the
- Xfirst disk.
- X
- XShip is a fixed-up version of a program I have been using myself for some
- Xtime in place of uuencode/uudecode. It's purpose is to facilitate sending
- Xzip files through the mail. It uses a more efficient coding scheme than
- Xuuencode (four bytes per five characters instead of three bytes per four
- Xcharacters) and includes a crc at the end of each file to check the
- Xveracity what was received. It can split its output to a specified size
- Xand recombine it automatically at the other end, verifying the sequence.
- XIt can also mail the parts to a specified address, with subject lines
- Xidentifying the parts, instead of making a bunch of files that you're just
- Xgoing to mail and delete anyway. Example:
- X
- X % ship -500 -m saddam@pickle.iq README zip07.zip
- X README shipped
- X zip07.zip shipped
- X files part0001..part0004 mailed
- X
- Xwill mail README and zip07.zip together in four chunks of 500 or fewer
- Xlines each. At the other end, Saddam can save the parts into the files
- Xnamed in the subject lines (part0001..part0004), and then do:
- X
- X % ship -u part*
- X README received
- X zip07.zip received
- X
- XFor now, zip.1 (and zip.doc) are incomplete as far as MSDOS goes. I'll
- Xput off doing that until the MSDOS version has stabilized. Likewise, I
- Xhave put off writing zipcloak.1, zipsplit.1, and ship.1 for the same
- Xreason.
- X
- XThere are, of course, all the little changes that fix bugs (what are
- Xthose?), make the Makefile work on more systems, documentation, and,
- Xfor the alert reader, an undocumented option ...
- X
- XAs usual, send reports to info-zip@wsmr-simtel20.army.mil, so everyone
- Xcan get a chuckle out of whatever new bugs I've introduced.
- X
- XMark Adler
- Xmadler@pooh.caltech.edu
- X
- X
- XChanges from release 0.6 to release 0.7:
- X
- X1. Changed Makefile to use mv instead of -o on compiles.
- X2. Added MAKE = make to Makefile.
- X3. Catch user interrupt or termination and delete temporary files.
- X4. Allow general purpose flags in local and central headers to differ in
- X the "reserved" bits. Keep both for copying zip entries verbatim.
- X5. Removed prototype for closedir--return value not used and inconsistent
- X across systems.
- X6. Wrote ZipSplit to break a large zip file into the smallest number of
- X zip files less than a specified size. Run zipsplit with no arguments
- X to see the command help.
- X7. Put error messages in globals.c to be common across zip, zipcloak, and
- X zipsplit. Use #define's in zip.h for error numbers.
- X8. Changed getp() to open a new file for the terminal device, and added
- X the echon() function to turn echoing back on when interrupted at
- X password prompt.
- X9. Added warn()'s to distinguish various zip file structure errors.
- X10. Allow "extra" fields in local and central headers to differ.
- X11. Fixed percent compression calculation to work for very large files.
- X12. Included the program (makecrc.c) that generates the CRC table.
- X makecrc.c is not compiled or run by the Makefile, but is present for
- X completeness.
- X13. Added an undocumented (except for here) option, -v, to zip that checks
- X for "oddities" in the zip file structure and points them out if found
- X (but continues processing).
- X14. Put prototypes in crypt.h inside #ifdef NeXT to avoid redefinition
- X problems with other compilers.
- X15. Added "make zilog" for Zilog S8000 running Zeus 3.21.
- X16. Minor changes to the manual page (zip.1 and zip.doc).
- X17. Fixed bug in replace() (manifested by -b option).
- X18. readzipfile() now also checks the central directory start and size in
- X the end of central directory header.
- X19. Allow modification of self-extracting zip files (exe instead of zip).
- X20. Allow .ZIP as valid suffix as well as .zip (also .EXE and .exe).
- X21. Cleaned up malloc usage, free'd everything malloc'ed.
- X22. fclose'd all fopen'ed files explicitly.
- X23. Corrected assignment of one ftell() result from an int to a long.
- X24. Considerably simplified Makefile, based on Jean-Loup Gailly's
- X suggestions.
- X25. Renamed unixfile.c to fileio.c in anticipation of non-unix support.
- X26. Removed const's (pesky little buggers caused too many problems).
- X27. Wrote my own shell expression compare routine, took REGEX and -lPW's
- X out of Makefile, which removed the sysvpw make option.
- X28. Added tempname() prototype to crypt.h for the implode routines to use.
- X29. Trying string.h for prototypes of string functions if __STDC__
- X defined, which is what unzip.h does.
- X30. Turned prototypes on if __STDC__ defined (we'll try this one more
- X time). They can be turned off using NOPROTO.
- X31. Improved source documentation.
- X32. Changed prototype of open in fileio.c to OF((char *, int, ...)).
- X33. Removed "local" from prototypes of main() (after all, it's *not*
- X local).
- X34. Wrote Ship program to supplant uuencode--slightly more efficient, has
- X error checking, file splitting, automatic mailing, other features.
- X Ship currently uses the command:
- X /usr/ucb/mail -s subject < tempfile
- X to send mail. Please let me know what works for your system. Note
- X that I want to be able to specify a subject line.
- X35. Ported to MSDOS Microsoft C 5.1, based on Jean-Loup Gailly's work.
- X36. Fixed add/update bug when -p not used.
- X37. Handle lower case conversion and devices (e.g. C:) for MSDOS.
- X38. Indented the #ifdef/#ifndef constructs that do not contain function
- X definitions, to improve the readability somewhat.
- X39. Cleaned up error handling. Now use perror() for i/o errors. Put the
- X errors and messages in ziperr.h.
- X40. Ported to MSDOS Turbo C++ 1.0.
- X41. Implemented wild card expansion on the command line for MSDOS and
- X handle MSDOS matching (*.* == all, not *).
- X42. Changed version required to unzip to 11 (1.10) since the implode
- X routines can procude an overlapping match one away from the end of the
- X window (PKUNZIP 1.00 requires two away from the end).
- X43. Changed old next make option to next10 (for version 1.0) and added a
- X new next make option for 2.0 (just called next) that uses the -object
- X linking option for smaller executables.
- X44. Added -z option to take a multi-line zip file comment from stdin.
- X45. Changed temporary names from $ZXXXXXX to _ZXXXXXX, where XXXXXX is
- X filled in by mktemp(). This avoids problems with "rm $Z*" in sh.
- X46. Got new implode routines from Rich that are (hopefully) PKUNZIP
- X compatible.
- X47. When -b is not specified, put the temporary files in the same
- X directory (i.e. the same device) that the zip file is (or will be) in.
- X48. Added doturboc.bat and domsc.bat files to compile for Turbo C++ 1.0
- X and Microsoft C 5.1. I am interested in successes and failures with
- X other versions of those compilers. In this version, the implode
- X routines do not work under MSDOS.
- X------------------------ May 6 1991 version 0.8 ------------------------
- XBuenos Dias Amigos,
- X
- XHeer ees dee Cinco de Mayo reeleese of seep, aka Zip 0.8. The changes
- Xfrom 0.7 are in the (long) list below, but here are some highlights:
- Xfaster implode, faster shrink, first attempt at a VMS version (thanks
- Xto Cave Newt), and a new program, ZipNote, to aid in editing zip file
- Xcomments. To compile under VMS, do an "@makevms.com". To compile using
- XMircosoft C do a "make makefile.msc". To compile using Borland (Turbo)
- XC, do a "make -fmakefile.bor". Please try to break any or all of these
- Xprograms in every conceivable way--we're getting close a public release.
- XThank yew fer your support.
- X
- XMark Adler
- Xmadler@pooh.caltech.edu
- X
- XChanges from 0.7 to 0.8:
- X
- X1. Added the -n option to prevent compressing already compressed files.
- X Documented -n in zip.1.
- X2. Check the length of the compressed data in zipup() in case implode or
- X shrink has a bug.
- X3. Fixed -v option to not complain about needing PKUNZIP 1.1.
- X4. Added report of store/shrink/implode sizes when -v (verbose) used.
- X5. Put in Rich's patch to fix 100% implosion bug.
- X6. Fixed -i bug.
- X7. Made changes to im_ctree.c and implode.c to (hopefully) make it work
- X under MSDOS. (Jean-Loup said declare topmaxvals and botmaxvals as
- X U_INT in im_ctree.c, and use MSDOS, not __MSDOS__ in implode.c.)
- X8 Added implode routine compilation to domsc.bat and doturboc.bat.
- X9. Replaced FILENAME_MAX with FNMAX, which is now always 1024. (It seems
- X FILENAME_MAX is incorrectly set to 14 on some System V Unixii.)
- X10. Changed BEST to -1 so it is different from STORE (=0). Redid some of
- X the method logic in zipup().
- X11. Changed wb+ to w+b in implode.c.
- X12. Removed "nothing to do" error for -u and -f.
- X13. Zip source distributions will now have tabs removed, except for
- X Makefile and Makefile.exp (no feelthy tabs rule).
- X14. Changed zip error on open failure to a warning. This accounts for
- X files that do not have read permission or are locked, and files
- X deleted during the zip. For entries being updated, the old entry is
- X copied over instead. This change had the side effect of removing the
- X zipskip() routine.
- X15. Removed OBJC dependencies in Makefile.exp (didn't belong).
- X16. Removed strip from Makefile, instead using the -s link option.
- X17. Fixed -um and -fm to delete files whose entry's times were checked in
- X the archive.
- X18. Put portability stuff common to zip.h and crypt.h into tailor.h.
- X19. Added mark tracing to -v (for debugging).
- X20. Changed name and zname logic--an external name is always converted
- X into an internal zname, and vice-versa. zname is now always
- X malloc'ed.
- X21. Fixed -z to use CRLF between lines (for PKZIP) and have no newline
- X after the last (or only) line.
- X22. Added clean to Makefile (deletes *.o, zip, zipcloak, zipsplit, ship).
- X23. Replaced LDFLAGS with LFLAGS1 and LFLAGS2 in Makefile (splits link
- X options before and after object files as in unzip).
- X24. Added scodos to Makefile (from Bill Davidsen).
- X25. Included stdio.h in tailor.h--removed stdio.h from zip.h and
- X implode.h.
- X26. Do not include stddef.h if M_XENIX defined.
- X27. Cast the arguments of all free() calls to (voidp *).
- X28. Added casts to char * for memset() and qsort() args in zipsplit.c.
- X29. Changed implode.h to define malloc and str* properly.
- X30. Fixed invlocal() to handle integer overflow correctly, as well as
- X reliably across compilers.
- X31. Got new implode.h from Rich with fix #29 above. Removed stdio.h
- X include.
- X32. Commented out the abort() calls in im_ctree.c.
- X33. -ee requests a verification of the encryption password.
- X34. malloc and free tempath.
- X35. Documented -, SCO, and scodos in zip.1, and - in help().
- X36. Added revision.h for Zip revision number and date.
- X37. -u and -f with no arguments now (both) freshen the entire archive.
- X38. Use /Oait instead of /Ox for MSC to avoid loop optimization (buggy on
- X 5.1, and sometimes even crashes compiler!).
- X39. Added ! (reverse) range matching to shmatch(), and early abort on '*'
- X failures (speeds up pathological patterns). Cleaned up '\' (escape)
- X handling.
- X40. Changed '!' in ship to '{' (some EBCDIC translations do not include
- X !). However, unship (ship -u) still understands '!'. Also added the
- X -v option of ship to print out the version and revision date. Also
- X now refuse to overwrite an existing file when unshipping (ship -u),
- X but there is a -o option to overwrite anyway.
- X41. Added a "fast" mode to ship using hard-arithmetic coding that is
- X nearly as efficient as base 85 coding, but much faster on 16-bit
- X machines (base 85 coding uses 32 bit multiplication and division).
- X42. Put tailor.h back in ship.c, so that ship.c can stand on its own.
- X43. Made -p the default, and added a new option, -j to do the opposite
- X (junk directory names). -p is still there but does nothing, so as to
- X avoid annoying PKZIP users. Changed documentation and help()
- X accordingly.
- X44. If -j is used, and two files are to be added with the same name, then
- X zip exits with an error.
- X45. Wrote ZipNote for editing zipfile comments. Just do zipnote for
- X usage.
- X46. Replaced Rich's im_lmat.c with a new one from Jean-Loup. Improves the
- X speed of implode by a factor of two, and even more for very large
- X files.
- X47. Reduced the execution time of shrink by 33% simply by moving the code
- X around (eliminated some unnecessary calls, moved some tests).
- X Shrink's execution time is now about 50% more than compress (it used
- X to take over twice as long). Hash tables for shrink are still
- X intended for a future release.
- X48. VMS mods from Greg: replace() unlinks only after copy, changed
- X delete() to destroy(), added code for deletedir(), use creation time
- X instead of modification time, warn if stamp() attempted, changed
- X includes, make link rename and unlink delete, added findfirst,
- X findnext stuff, added wild() for VMS, modified newname(), procname().
- X49. Implemented internal<-->external name conversions for MSDOS and VMS.
- X50. For VMS matching, changed ? to %, removed bracketed ranges.
- X51. Added makevms.com, stolen from Unzip (vms_make.com).
- X52. Implemented -k (force the zip file to look like it was made by PKZIP).
- X53. Removed implode for VMS (it crashes--haven't tracked down where).
- X54. Got Jean-Loup's makefile.dos working for MSC 5.1 (makefile.msc) and
- X Turbo C++ 1.0 (makefile.bor).
- X------------------------ Jul 11 1991 version 0.9 ------------------------
- XHey gang,
- X
- XHere is our very-nearly-ready-to-release version of Zip. There will be no
- Xfeatures added or changed from 0.9 to 1.0--only bugs fixed. I hope that
- Xwe can get 1.0 out pretty quickly then. This is really your last chance to
- Xfind bugs before it goes out, so please, please test all the programs as
- Xmuch as you can. Try all the features, if possible, and perhaps try to
- Xthink of ways to break the programs. Also, and this is very important, read
- Xthe documentation in zip.doc and "debug" that too. I already know that it
- Xis not complete in 0.9, but please send any comments about errors, omissions,
- Xformat, or whatever to Info-ZIP, even if they seem obvious.
- X
- XThe highlights of the changes from 0.8 to 0.9 are: faster, slicker implode;
- Xoperation in small model on MSDOS for speed; a new temporary file interface
- Xfor faster operation on small files; some shrink improvements; and some new
- Xoptions (-y, -g, -q). Also, ship has been enhanced in several ways, not the
- Xleast of which is a help option (-h).
- X
- XHave fun.
- X
- XMark Adler
- Xmadler@tybalt.caltech.edu
- X
- X
- XChanges from 0.8 to 0.9:
- X
- X1. Removed the "not implemented yet" note in help() for -k (it *is*
- X implemented now). Removed from bug list in zip.1 too.
- X2. Fixed Turbo C implode bug.
- X3. Added /link /e in makefile.msc for ship.c.
- X4. Made handler() in zipnote.c the same as handler() in zipsplit.c.
- X5. Added -y option in Unix to store symbolic links as such. (We need
- X Unzip to be aware of symbolic links and use symlink() to recreate them.)
- X6. Ignore control characters in unship input.
- X7. Use prototypes and ANSI libraries if MSDOS. (Used to check for Turbo C,
- X but Microsoft C 6.0 also does not define __STDC__ unless strict ANSI
- X is requested.)
- X8. Added mod to ct_fsort() from Rich that should remove any qsort()
- X dependencies in implode output.
- X9. Removed some 32/16-bit prejudices in util.c and crypt.c that affect
- X 64-bit integer (short, int, and long) machines (Cray).
- X10. Added System V MAILX option to ship.c to use the mailx command. This
- X is automatically activated by DIRENT if ship is compiled by the zip
- X makefile.
- X11. Added patches from Greg Roelofs for echo control on Cray and Amdahl.
- X The patch uses termio.h and ioctl(), and is assumed for all System V,
- X not just those (we'll see how this flies).
- X12. Changed -Ox to -Oacegit -FPi87 in makefile.msc. Added /nologo to link.
- X13. Applied J-L's 082 mods (Sinatra style): select 4K window for < 5.5K,
- X 8K window for >= 5.5K files (just like PK does); various im_ctree.c
- X mods verbatim (except for the treename warning, which I did differently);
- X various im_lmat.c mods verbatim (except macros are done the ugly portable
- X way); farmalloc'ed in shrink.c; changed makefile.msc and makefile.bor to
- X use small model; added J-L to zip.1 acknowledgements (oops).
- X14. Moved struct zlist's and struct flist's to far storage (needed by above
- X mods). Unfortunately, I can't move the names and other things pointed to
- X by those structures into the far space, since they are arguments to
- X library functions like strcmp() and fwrite().
- X15. Changed zipup() to both shrink and implode only on files smaller than
- X BSZ. Also in that case, free up shrink data structures before allocating
- X the implode data structures. Changed from fopen() to open() except for
- X VMS.
- X16. Fixed bug in dosmatch() to free malloc'ed space.
- X17. MINIX mods (do not need minix make option): call tempname() with a unique
- X character (MINIX mktemp() flawed); defined S_IWRITE as S_IWUSR if S_IWUSR
- X defined; removed explicit signal dereference.
- X18. Fixed bug in unship when used as a filter with no args.
- X19. Changed getnam() to not use static storage.
- X20. Copy permissions from old to new zip file (zip, zipcloak, zipnote).
- X21. Added patches for AT&T 3B1, added 3b1 target to makefile, added to zip.1.
- X22. Made FNMAX 256 for MSDOS (is 1024 otherwise).
- X23. Used the "pyr" predefined symbol for Pyramid systems in tailor.h.
- X24. Added Greg's VMS mods to ship.c. Added help to ship.c (-h or -?).
- X Changed meaning of -nnn arg from lines to K.
- X25. Moved ZMEM routines to fileio.c to properly include them in zipnote and
- X zipsplit.
- X26. Added -s option to ship to specify a subject line prefix.
- X27. Fixed -z in zip to not trash leading blank lines in the comment.
- X28. Made ship recognize "unship" in argv[0] a little more flexibly.
- X29. Made sure temporary zip files are closed before being deleted by an
- X error or interrupt.
- X30. Added a new temporary file interface and new source files tempf.c and
- X tempf.h. This avoids making temporary files for small (<16k) output.
- X Both shrink and implode use this.
- X31. Added OS/2 patches, files. However, left zip case-sensitive for OS/2
- X names, as in Unix.
- X32. Removed amdahl target in makefile, using UTS symbol instead.
- X33. Changed -y to depend on definition of S_IFLNK.
- X34. Avoid leading periods on lines in ship output by inserting a space.
- X35. Ship is now extensible: added a warning for "unsupported keyword".
- X Such keywords can appear before the "ship" line, for example.
- X36. Added -g option to allow "growing" the zip file. If just adding new
- X entries to a zip file, -g will write over the old zip file without
- X creating a temporary. The danger is that if there is an error, the
- X old zip file will be lost. If not just adding, then -g is ignored.
- X37. Added aux (A/UX) target to makefile.
- X38. In shrink.c, removed unnecessary FreeList and ClearList arrays, and
- X the recursive Prune() routine. This also resulted in a speedup in
- X shrink of about 15%. It is now only about 30% slower than Unix compress.
- X39. Added -q option for quiet operation.
- X------------------------ Sep 21 1991 version 1.0 ------------------------
- XHello world!
- X
- XThis is the first public release version of Zip and its cohort utilities.
- XWe hope you enjoy using it much much more than we enjoyed writing it and
- Xtrying to get it to work on every fritzing raffing bliffing nobbin Unix
- Xsystem in the galaxy.
- X
- XPlease feel free to send any problems, complaints, suggestions, kudos,
- Xridicule, or whatever to zip-bugs@cs.ucla.edu. If there were a way to
- Xsend cookies over the net, we'd accept those too.
- X
- XThank yew fer yur support.
- X
- XMark Adler
- Xmadler@tybalt.caltech.edu
- X
- X
- XChanges from 0.9 to 1.0:
- X
- X1. Removed some pesky carriage returns masquerading as spaces in fileio.c
- X and zipup.c.
- X2. Removed #include memory.h in tempf.c (string.h good enough).
- X3. Compile ship in doturboc.bat.
- X4. Miscellaneous zip.1 (zip.doc) changes.
- X5. Fixed mistake in stamp() in fileio.c (didn't double seconds).
- X6. Applied Jean-Loup's mods for Cray's (do not assume 16-bit shorts).
- X7. Removed pyramid make option, since #ifdef pyr seems to work.
- X8. Added some casts to tempf.c to clean up some warnings.
- X9. Added comment to makefile.exp saying what it is.
- X10. Removed length checks in zipup.c to fix problem with using Vax variable
- X record length formats.
- X11. Fixed VMS replace-across-devices problem.
- X12. Changed order of include's in implode.h to make tailor.h show up first.
- X13. Added Convex mods and make target.
- X14. Fixed path delimiter under VMS for unship.
- X15. Added ship to makevms.com.
- X16. Put in new copyright messages.
- X17. Added aix make target.
- X18. Fixed zipsplit.idx to start counting at one like the file names.
- X19. Changed -a (append VMS version number) to -w to leave -a open for a
- X possible future option.
- X20. Back to separate makefiles for Microsoft and Borland (.msc and .bor).
- X21. Workaround in fileio.c for Borland stat() bug: stat() succeeds for wild
- X card names that match existing files.
- X22. Added "(did you remember to use binary mode when you transferred it?)"
- X to the "probably not a zip file" warning.
- X23. Changed utilities to append .zip only when the zip file name does not
- X contain a dot.
- X24. At least mentioned the other utilities in zip.doc (zipcloak, ship, etc.),
- X and documented upper case matching of names when using -d under MSDOS.
- X25. Fixed bug in MSDOS version: zip foo c:autoexec.bat wouldn't work.
- X26. Added hidden/system attribute bug to BUGS in zip.1
- X27. Fixed recognition of unship in ship when unship is in a path.
- X28. Added non-stream-LF VMS bug to zip.1 bug list.
- X29. Fixed bug in #23 above when path has dots. Documented #23 in zip.1.
- X30. Show disclaimer only for -l, add -h and -l to zip utilities.
- X31. Applied Minix patches.
- END_OF_FILE
- if test 36825 -ne `wc -c <'History'`; then
- echo shar: \"'History'\" unpacked with wrong size!
- fi
- # end of 'History'
- fi
- if test -f 'makefile.pwc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makefile.pwc'\"
- else
- echo shar: Extracting \"'makefile.pwc'\" \(3619 characters\)
- sed "s/^X//" >'makefile.pwc' <<'END_OF_FILE'
- X# Makefile for Zip, ZipNote, ZipSplit, and Ship, for Power C.
- X
- X# This version by Bob Hardy, 07-16-91
- X
- X# Make sure you have plenty of free diskspace before invoking make,
- X# especially for "make zips". If you run out of space, several lines
- X# will lose dramatically, and the make will fail. You may even have
- X# to rename some source files.
- X
- XCC=pc
- XLD=pcl
- XMODEL=m
- X# (note from the editor: the "m" here for MODEL looks a little suspicious--
- X# it probably should be s or c, since the small or compact models are what
- X# should be used.)
- XCFLAGS=/f- /m$(MODEL) /dMSDOS /dNO_ASM /dEXPORT
- XLDFLAGS=/d
- XSTRIP=lzexe
- X# If you don't have lzexe, get it. Then define:
- X# STRIP=lzexe
- X# This makes a *big* difference in .exe size (hence load time)
- X# If you want to make without it, comment out all the STRIP lines and the
- X# "rm *.old" lines. This will cost you in terms of disk usage, though.
- X
- X# variables
- XOBJZ1 = zip.mix zipfile.mix zipup.mix fileio.mix util.mix
- XOBJZ2 = shrink.mix globals.mix tempf.mix
- XOBJC2 = util.mix globals.mix
- XOBJI = implode.mix im_lmat.mix im_ctree.mix im_bits.mix
- XOBJN = zipnote.mix zipfile_.mix zipup_.mix fileio_.mix globals.mix
- XOBJS = zipsplit.mix zipfile_.mix zipup_.mix fileio_.mix globals.mix
- X
- Xzips: zip.exe zipnote.exe zipsplit.exe ship.exe
- X
- Xzip.mix: zip.h ziperr.h tailor.h revision.h zip.c
- X $(CC) $(CFLAGS) zip.c
- X
- Xzipfile.mix: zip.h ziperr.h tailor.h zipfile.c
- X $(CC) $(CFLAGS) zipfile.c
- X
- Xzipup.mix: zip.h ziperr.h tailor.h revision.h zipup.c
- X $(CC) $(CFLAGS) zipup.c
- X
- Xfileio.mix: zip.h ziperr.h tailor.h fileio.c
- X $(CC) $(CFLAGS) fileio.c
- X
- Xutil.mix: zip.h ziperr.h tailor.h util.c
- X $(CC) $(CFLAGS) util.c
- X
- Xshrink.mix: zip.h ziperr.h tailor.h shrink.c
- X $(CC) $(CFLAGS) shrink.c
- X
- Xglobals.mix: zip.h ziperr.h tailor.h globals.c
- X $(CC) $(CFLAGS) globals.c
- X
- Xzipnote.mix: zip.h ziperr.h tailor.h revision.h zipnote.c
- X $(CC) $(CFLAGS) zipnote.c
- X
- Xzipsplit.mix: zipsplit.c zip.h ziperr.h tailor.h revision.h
- X $(CC) $(CFLAGS) zipsplit.c
- X
- Ximplode.mix: implode.h crypt.h ziperr.h tailor.h tempf.h implode.c
- X $(CC) $(CFLAGS) implode.c
- X
- Xtempf.mix: tempf.h tailor.h tempf.c
- X $(CC) $(CFLAGS) tempf.c
- X
- Xim_lmat.mix: implode.h crypt.h ziperr.h tailor.h im_lmat.c
- X $(CC) $(CFLAGS) im_lmat.c
- X
- Xim_ctree.mix: implode.h crypt.h ziperr.h tailor.h tempf.h im_ctree.c
- X $(CC) $(CFLAGS) im_ctree.c
- X
- Xim_bits.mix: implode.h crypt.h ziperr.h tailor.h im_bits.c
- X $(CC) $(CFLAGS) im_bits.c
- X
- Xzipfile_.mix: zipfile.c zip.h
- X +ren zipfile.c zipfile_.c
- X $(CC) /dUTIL $(CFLAGS) zipfile_.c
- X +ren zipfile_.c zipfile.c
- X
- Xzipup_.mix: zipup.c zip.h
- X +ren zipup.c zipup_.c
- X $(CC) /dUTIL $(CFLAGS) zipup_.c
- X +ren zipup_.c zipup.c
- X
- Xfileio_.mix: fileio.c zip.h
- X +ren fileio.c fileio_.c
- X $(CC) /dUTIL $(CFLAGS) fileio_.c
- X +ren fileio_.c fileio.c
- X
- X# we must cut the command line to fit in the MS/DOS 128 byte limit:
- Xzip.exe: $(OBJZ1) $(OBJZ2) $(OBJI)
- X +echo L $(OBJZ1) > zip.rsp
- X +echo L $(OBJZ2) >> zip.rsp
- X +echo L $(OBJI) >> zip.rsp
- X +echo FA; >> zip.rsp
- X +echo b zip,,, >> zip.rsp
- X $(LD) $(LDFLAGS) @zip.rsp
- X rm zip.rsp
- X $(STRIP) zip.exe
- X# rm zip.old
- X# Leave these "rm *.old" lines in if you have a shortage of diskspace.
- X# Particularly if you intend to "make zips".
- X
- Xzipnote.exe: $(OBJN)
- X +echo L $(OBJN) > zipn.rsp
- X +echo FA; >> zipn.rsp
- X +echo b zipnote,,, >> zipn.rsp
- X $(LD) $(LDFLAGS) @zipn.rsp
- X rm zipn.rsp
- X $(STRIP) zipnote.exe
- X# rm zipnote.old
- X
- Xzipsplit.exe: $(OBJS)
- X +echo L $(OBJS) > zips.rsp
- X +echo FA; >> zips.rsp
- X +echo b zipsplit,,, >> zips.rsp
- X $(LD) $(LDFLAGS) @zips.rsp
- X rm zips.rsp
- X $(STRIP) zipsplit.exe
- X# rm zipsplit.old
- X
- Xship.exe: ship.c
- X $(CC) $(CFLAGS) ship.c
- X $(LD) $(LDFLAGS) ship.mix
- X $(STRIP) ship.exe
- X# rm ship.old
- END_OF_FILE
- if test 3619 -ne `wc -c <'makefile.pwc'`; then
- echo shar: \"'makefile.pwc'\" unpacked with wrong size!
- fi
- # end of 'makefile.pwc'
- fi
- if test -f 'shrink.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'shrink.c'\"
- else
- echo shar: Extracting \"'shrink.c'\" \(10431 characters\)
- sed "s/^X//" >'shrink.c' <<'END_OF_FILE'
- X/*
- X
- X Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
- X Permission is granted to any individual or institution to use, copy, or
- X redistribute this software so long as all of the original files are included
- X unmodified, that it is not sold for profit, and that this copyright notice
- X is retained.
- X
- X*/
- X
- X/*
- X * shrink.c by Mark Adler.
- X */
- X
- X#include "zip.h"
- X#include "tempf.h"
- X
- X
- X/*
- X Shrink.Pas version 1.2 by R. P. Byrne, 1989 (in Pascal and assembler).
- X We here heartily acknowledge R. P. Byrne's contribution to this project.
- X The existence of this program really triggered our efforts to write a
- X portable Unix zip. What little remains of Byrne's program lies in this
- X source file, and those remnants are mostly in the variable and routine
- X names, since it has been translated and extensively modified and rewritten.
- X
- X Stolen, translated into C, and modified by Mark Adler, 11 October 1990.
- X Severely modified again by Mark Adler, 11 July 1991, to remove the
- X unnecessary FreeList and ClearTable arrays, and to replace the recursive
- X Prune() routine with a non-recursive method.
- X As Stravinsky once said: "Mediocre composers plagiarize.
- X Great composers steal."
- X*/
- X
- X/* Compress a set of input files into a Zip file using Lempel-Ziv-Welch */
- X/* (LZW) compression techniques (the "shrink" method). */
- X
- X
- X#define MINBITS 9 /* Starting code size of 9 bits */
- X#define MAXBITS 13 /* Maximum code size of 13 bits */
- X#define TABLESIZE 8191 /* We'll need 4K entries in table */
- X#define SPECIAL 256 /* Special function code */
- X#define INCSIZE 1 /* Code for a jump in code size */
- X#define CLEARCODE 2 /* Code for code table has been cleared */
- X#define FIRSTENTRY 257 /* First available table entry */
- X
- X
- X/* Define data types needed to implement a code table for LZW compression */
- X
- Xtypedef struct CodeRec {
- X /* Code Table record format... */
- X short Child; /* Addr of 1st suffix for this prefix */
- X short Sibling; /* Addr of next suffix in chain */
- X uch Suffix; /* Suffix character */
- X} CodeRec;
- X
- Xtypedef CodeRec CodeArray[TABLESIZE + 1]; /* Define the code table */
- X
- X
- X
- X/* Private globals */
- Xlocal CodeRec far *CodeTable; /* Points to code table for LZW compression */
- X
- Xlocal int NextFree; /* Next free table entry */
- X
- Xlocal int CodeSize; /* Size of codes (in bits) currently being written */
- Xlocal int MaxCode; /* Largest code that can be written in CodeSize bits */
- X
- Xlocal int FirstCh; /* Flag indicating the START of a shrink operation */
- X
- Xlocal tFILE *tempf = NULL; /* Temporary file */
- Xlocal ulg count; /* Count of bytes written */
- X
- X
- X/* Local functions */
- X#ifdef PROTO
- X local void PutCode(int);
- X local int Build_Data_Structures(void);
- X local void Destroy_Data_Structures(void);
- X local void Initialize_Data_Structures(void);
- X local void Clear_Table(void);
- X local void Table_Add(int, int);
- X#endif /* PROTO */
- X
- X
- X/* Macro for PutCode() that writes to tempf and counts bytes in count */
- X#define PUT(c) {tputc(c, tempf); count++;}
- X
- Xlocal void PutCode(c)
- Xint c; /* code to send */
- X/* Write out the low CodeSize bits of c using the PUT macro. If c is -1,
- X then flush the bit buffer. Assumes CodeSize < 16. By Mark Adler. */
- X{
- X static int b = 0; /* current bits waiting to go out */
- X static int n = 0; /* number of bits in b */
- X /* masks for all bit values */
- X static int x[] = {0, 1, 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff,
- X 0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff};
- X
- X if (c == -1)
- X {
- X if (n)
- X {
- X if (n > 8)
- X {
- X PUT((char)b)
- X PUT((char)((b >> 8) & x[n - 8]))
- X }
- X else
- X PUT((char)(b & x[n]))
- X b = n = 0;
- X }
- X }
- X else
- X {
- X b |= (c & x[CodeSize]) << n;
- X n += CodeSize;
- X if (n >= 16)
- X {
- X PUT((char)b)
- X PUT((char)(b >> 8))
- X if (n == 16)
- X b = n = 0;
- X else
- X {
- X n -= 16;
- X b = (c >> (CodeSize - n)) & x[n];
- X }
- X }
- X }
- X}
- X
- X
- X
- Xlocal int Build_Data_Structures()
- X/* Allocate tables for shrinking. Return true on failure. */
- X{
- X return (CodeTable = (CodeRec far *)farmalloc(sizeof(CodeArray))) == NULL;
- X}
- X
- X
- X
- Xlocal void Destroy_Data_Structures()
- X/* Deallocate tables for shrinking. */
- X{
- X if (CodeTable != NULL)
- X {
- X farfree((voidp far *)CodeTable);
- X CodeTable = NULL;
- X }
- X}
- X
- X
- X
- Xlocal void Initialize_Data_Structures()
- X/* Clear tables for shrinking. */
- X{
- X int i; /* counter for table entries */
- X CodeRec far *t; /* pointer to current table entry */
- X
- X /* Initialize parent symbols */
- X for (i = 0, t = CodeTable; i <= 255; i++, t++)
- X {
- X t->Child = -1;
- X t->Suffix = (uch)i;
- X }
- X
- X /* Build free list */
- X NextFree = FIRSTENTRY;
- X for (i = FIRSTENTRY, t = CodeTable + FIRSTENTRY; i < TABLESIZE; i++, t++)
- X t->Child = i + 1;
- X t->Child = -1;
- X}
- X
- X
- X
- Xlocal void Clear_Table()
- X/* Clear the leaves of the tree--assume all entries used (NextFree == -1) */
- X{
- X int n; /* node counter */
- X CodeRec far *p; /* pointer to next node to look at */
- X short far *q; /* pointer to node child or sibling entry */
- X
- X /* Mark leaf nodes */
- X p = CodeTable + TABLESIZE;
- X n = TABLESIZE + 1 - FIRSTENTRY;
- X do {
- X if (p->Child == -1)
- X p->Child = -2;
- X p--;
- X } while (--n);
- X
- X /* Shake leaves from tree */
- X p = CodeTable;
- X n = 256;
- X do {
- X q = &p->Child;
- X while (*q != -1 && CodeTable[*q].Child == -2)
- X *q = CodeTable[*q].Sibling;
- X p++;
- X } while (--n);
- X p = CodeTable + FIRSTENTRY;
- X n = TABLESIZE + 1 - FIRSTENTRY;
- X do {
- X if (p->Child != -2)
- X {
- X q = &p->Child;
- X while (*q != -1 && CodeTable[*q].Child == -2)
- X *q = CodeTable[*q].Sibling;
- X q = &p->Sibling;
- X while (*q != -1 && CodeTable[*q].Child == -2)
- X *q = CodeTable[*q].Sibling;
- X }
- X p++;
- X } while (--n);
- X
- X /* Build the list of free table entries */
- X NextFree = -1;
- X p = CodeTable + TABLESIZE;
- X n = TABLESIZE + 1 - FIRSTENTRY;
- X do {
- X if (p->Child == -2)
- X {
- X p->Child = NextFree;
- X NextFree = n + FIRSTENTRY - 1;
- X }
- X p--;
- X } while (--n);
- X}
- X
- X
- X
- Xlocal void Table_Add(p, s)
- Xint p; /* prefix to add to */
- Xint s; /* suffix to add to it */
- X/* Add an entry to the table. */
- X{
- X int f; /* next free node */
- X
- X if ((f = NextFree) != -1)
- X {
- X NextFree = CodeTable[f].Child;
- X CodeTable[f].Child = -1;
- X CodeTable[f].Sibling = -1;
- X CodeTable[f].Suffix = (uch)s;
- X if (CodeTable[p].Child == -1)
- X CodeTable[p].Child = f;
- X else
- X {
- X p = CodeTable[p].Child;
- X while (CodeTable[p].Sibling != -1)
- X p = CodeTable[p].Sibling;
- X CodeTable[p].Sibling = f;
- X }
- X }
- X}
- X
- X
- Xlocal int lastcode;
- X
- Xint shr_setup()
- X/* Initialize shrink() routines. Return an error code in the ZE_ class. */
- X{
- X if (Build_Data_Structures())
- X return ZE_MEM;
- X Initialize_Data_Structures();
- X FirstCh = 1;
- X lastcode = -1;
- X if ((tempf = topen('S')) == NULL)
- X return ZE_MEM;
- X count = 0;
- X return ZE_OK;
- X}
- X
- X
- Xint shr_p1(b, n)
- Xuch *b; /* buffer with bytes to shrink */
- Xextent n; /* number of bytes in buffer */
- X/* Shrink n bytes at *b. Return an error code in the ZE_ class. */
- X{
- X int f; /* result of Table_Lookup */
- X int s; /* byte to shrink */
- X
- X if (FirstCh && n)
- X { /* If just getting started ... */
- X CodeSize = MINBITS; /* Initialize code size to minimum */
- X MaxCode = (1 << CodeSize) - 1;
- X lastcode = *b++; n--; /* get first character from input, */
- X FirstCh = 0; /* and reset the first char flag. */
- X }
- X while (NextFree == -1 && n)
- X {
- X /* Ok, lets clear the code table (adaptive reset) */
- X PutCode(lastcode);
- X PutCode(SPECIAL);
- X PutCode(CLEARCODE);
- X Clear_Table();
- X Table_Add(lastcode, s = *b++); n--;
- X lastcode = s;
- X }
- X while (n)
- X {
- X s = *b++; n--;
- X f = CodeTable[lastcode].Child;
- X while (f != -1 && CodeTable[f].Suffix != (uch)s)
- X f = CodeTable[f].Sibling;
- X if (f != -1)
- X /* If lastcode:s pair is found in the code table, then ... */
- X /* ... set lastcode to the entry where the pair is located */
- X lastcode = f;
- X else
- X {
- X /* Not in table */
- X PutCode(lastcode); /* Write current lastcode */
- X Table_Add(lastcode, s); /* Attempt to add to code table */
- X lastcode = s; /* Reset lastcode for new char */
- X if (NextFree > MaxCode && CodeSize < MAXBITS)
- X {
- X /* Time to increase the code size and change the max. code */
- X PutCode(SPECIAL);
- X PutCode(INCSIZE);
- X CodeSize++;
- X MaxCode = (1 << CodeSize) - 1;
- X }
- X while (NextFree == -1 && n)
- X {
- X /* Ok, lets clear the code table (adaptive reset) */
- X PutCode(lastcode);
- X PutCode(SPECIAL);
- X PutCode(CLEARCODE);
- X Clear_Table();
- X Table_Add(lastcode, s = *b++); n--;
- X lastcode = s;
- X }
- X }
- X }
- X return ZE_OK;
- X}
- X
- X
- Xint shr_size(s)
- Xulg *s; /* return value: size of shrunk data */
- X/* End shrink and return size of shrunk data in *s. Return an error code in
- X the ZE_ class. */
- X{
- X PutCode(lastcode); /* Write last prefix code */
- X PutCode(-1); /* Tell putcode to flush remaining bits */
- X Destroy_Data_Structures();
- X *s = count;
- X return tflush(tempf) || terror(tempf) ? ZE_TEMP : ZE_OK;
- X}
- X
- X
- Xint shr_p2(f)
- XFILE *f; /* file to write shrunk data to */
- X/* Copy shrunk data from temporary file to zip file *f. Return an error
- X code in the ZE_ class. */
- X{
- X char *b; /* malloc'ed buffer for copying */
- X extent k; /* holds result of fread */
- X
- X if ((b = malloc(BSZ)) == NULL)
- X return ZE_MEM;
- X trewind(tempf);
- X while ((k = tread(b, 1, BSZ, tempf)) > 0)
- X if (zfwrite(b, 1, k, f) != k)
- X {
- X free((voidp *)b);
- X return ZE_TEMP;
- X }
- X free((voidp *)b);
- X if (terror(tempf))
- X return ZE_TEMP;
- X tclose(tempf);
- X tempf = NULL;
- X return ZE_OK;
- X}
- X
- X
- Xint shr_clear()
- X/* Terminate shrink procedure (at any time). Return an error code in
- X the ZE_ class (always ZE_OK). */
- X{
- X Destroy_Data_Structures();
- X if (tempf != NULL)
- X {
- X tclose(tempf);
- X tempf = NULL;
- X }
- X return ZE_OK;
- X}
- END_OF_FILE
- if test 10431 -ne `wc -c <'shrink.c'`; then
- echo shar: \"'shrink.c'\" unpacked with wrong size!
- fi
- # end of 'shrink.c'
- fi
- if test -f 'zip.def' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'zip.def'\"
- else
- echo shar: Extracting \"'zip.def'\" \(86 characters\)
- sed "s/^X//" >'zip.def' <<'END_OF_FILE'
- XNAME WINDOWCOMPAT NEWFILES
- XDESCRIPTION 'The world-famous zip utilities from Info-ZIP'
- END_OF_FILE
- if test 86 -ne `wc -c <'zip.def'`; then
- echo shar: \"'zip.def'\" unpacked with wrong size!
- fi
- # end of 'zip.def'
- fi
- echo shar: End of archive 4 \(of 9\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 9 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-